#ifndef SERIALDEBUG_H
#define SERIALDEBUG_H

#include <QMainWindow>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QStringList>
#include "serial_info.h"
#include <QFile>
#include <QThread>
#include <QString>
#include <showdataforgraph.h>

QT_BEGIN_NAMESPACE
namespace Ui { class SerialDebug; }
QT_END_NAMESPACE

class SerialDebug : public QMainWindow
{
    Q_OBJECT

public:
    SerialDebug(QWidget *parent = nullptr);
    ~SerialDebug();

private slots:
    void readSerialData(const QByteArray res);
    void showSerialCom(const QStringList &strList);
    void GraphWindowClose();
    void on_serial_switch_btn_clicked();
    void on_recount_btn_clicked();
    void on_clear_data_btn_clicked();
    void on_save_data_btn_clicked();
    void on_pushButton_clicked();
    void on_send_btn_clicked();

signals:
    void scanSerial();
    void openSerial(QString serialName, int baudRate,
                    int _databit, int _parity,
                    int _stopbit);
    void GraphShowData(const QString &str);

private:
    Ui::SerialDebug *ui;

    SerialClass *SerialControler;
    QThread *serialThread;
    int receive_count,send_count;
    QByteArray readbuf;
    showDataForGraph *dataShowPtr;
};
#endif // SERIALDEBUG_H
